package com.lingx.web.api.impl;

import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import com.lingx.interfaces.ILoginVerifyService;
import com.lingx.service.LingxService;
import com.lingx.utils.Utils;
import com.lingx.web.api.ApiService;
import com.lingx.web.api.IApi;
import com.lingx.web.core.urihanlder.KaptchaHandler;
@Component
public class Api8016 extends AbstractApi implements IApi{

	@Resource
	private JdbcTemplate jdbcTemplate;
	@Resource
	private LingxService lingxService;
	@Resource
	private List<ILoginVerifyService> listLoginVerifyServices;
	@Override
	public int getApiCode() {
		return 8016;
	}
	@Override
	public String getApiName() {
		return "发送手机验证码接口";
	}
	@Override
	public Map<String, Object> api(Map<String, Object> params) {
		Map<String,Object> ret=IApi.getRetMap(1, "操作成功");
		if(this.checkIsNull(params, "account",ret))return ret; 
		String account=IApi.getParamString(params, "account", "");
		String verifyType=this.lingxService.getConfigValue("lingx.login.verify.type", "verify_code");
		boolean b=false;
		for(ILoginVerifyService lvs:this.listLoginVerifyServices) {
			if(verifyType.equals(lvs.getCode())) {
				b=lvs.sendVerifyCode(account, params);
			}
		}
		if(!b) {
			ret.put("code", -1);
			ret.put("message", this.lingxService.getConfigValue("lingx.login.verify.sendcode.errmsg", "操作失败"));
		}
		return ret;
	}
	public boolean isLog() {
		return false;
	}
}
